class UserInfoModel {
  static const tableName = "im_user_info";

  static const createTableSQL = """
      CREATE TABLE $tableName (
        id CHAR(32) PRIMARY KEY NOT NULL,
        avatar VARCHAR(120) NOT NULL,
        phone CHAR(11) NOT NULL,
        nickName VARCHAR(20) NOT NULL,
        note VARCHAR(20) NOT NULL,
        city VARCHAR(20) NOT NULL,
        token VARCHAR(100) NOT NULL,
        expirationTime INT NOT NULL 
      )""";

  static const columnSQL = "id, avatar, phone, nickName, note, city, token, expirationTime";

  static const findAllSQL = """
  select $columnSQL from $tableName limit 1
  """;

  static const insertSQL = """
  insert into $tableName ($columnSQL) values (?,?,?,?,?,?,?,?)
  """;

  static const deleteSQL = """
  delete from $tableName where id = ?
  """;

  String id;

  String avatar;

  String phone;

  String nickName;

  String note;

  String city;

  String token;

  DateTime expirationTime;


  UserInfoModel({this.id, this.avatar, this.phone, this.nickName, this.note,
      this.city, this.token, this.expirationTime});


  static UserInfoModel fromJson(Map<String, dynamic> map) {
    int time = map["expirationTime"];

    return UserInfoModel(
        id: map["id"],
        avatar: map["avatar"],
        phone: map["phone"],
        nickName: map["nickName"],
        note: map["note"],
        city: map["city"],
        token: map["token"],
        expirationTime: DateTime.fromMillisecondsSinceEpoch(time * 1000));
  }

  @override
  String toString() {
    return 'UserInfoModel{id: $id, avatar: $avatar, phone: $phone, nickName: $nickName, note: $note, city: $city, token: $token, expirationTime: $expirationTime}';
  }


}
